package com.yuanli.cosmeticmirror.persenter;

import androidx.lifecycle.LifecycleOwner;

import com.comenjoysoft.baselibrary.listener.CallbackListener;
import com.comenjoysoft.baselibrary.presenter.BasePresenter;
import com.yuanli.cosmeticmirror.bean.PhotoFrame;
import com.yuanli.cosmeticmirror.bean.PhotoFrameBean;
import com.yuanli.cosmeticmirror.model.biz.IPhotoFrameBiz;
import com.yuanli.cosmeticmirror.model.impl.PhotoFrameImpl;
import com.yuanli.cosmeticmirror.model.iview.IPhotoFrameView;

import java.util.List;

public class PhotoFramePersenter extends BasePresenter<IPhotoFrameView> {
    private final IPhotoFrameBiz biz;

    public PhotoFramePersenter(IPhotoFrameView view, LifecycleOwner owner) {
        attachView(view);
        biz = new PhotoFrameImpl(owner);
    }

    public void getPhotoFrame() {
        biz.getPhotoFrame(new CallbackListener<PhotoFrame>() {
            @Override
            public void success(PhotoFrame object) {
                mView.sucess(object);
            }

            @Override
            public void failed(Object object) {
                mView.error("获取相框类型失败");
            }
        });
    }

    public void getPhotoFrameById(String id) {
        biz.getPhotoFrameForId(id, new CallbackListener<List<PhotoFrameBean>>() {
            @Override
            public void success(List<PhotoFrameBean> object) {
                mView.getPhotoFrame(object);
            }

            @Override
            public void failed(Object object) {
                mView.error("获取相框失败");
            }
        });
    }
}
